package com.xiaoq;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xiaoq.coms.GenericResponse;

@RestController
@RequestMapping(value = "/api/v1")
class TokenExceptionEndpoint {

	private static Logger logger = LoggerFactory.getLogger(TokenExceptionEndpoint.class);

	@RequestMapping(value = "/token_exception", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	public GenericResponse HandlerException(HttpServletRequest request) {

		Integer rc = (Integer) request.getAttribute("rc");
		String msg = (String) request.getAttribute("msg");

		if (logger.isDebugEnabled()) {
			logger.debug("rc = " + rc);
			logger.debug("msg = " + msg);
		}
		GenericResponse resp = new GenericResponse();
		resp.setRc(rc + "");
		resp.setMsg(msg);
		return resp;
	}
}
